using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace LitTools
{
    public class BTNode_Composite_Selector : BTNode_Composite
    {
        private int childIndex;

        protected override void OnStart()
        {
            childIndex = 0;
        }

        protected override BTNodeState OnUpdate()
        {
            var child = children[childIndex];
            var state = child.Update();
            if (state == BTNodeState.Failure)
            {
                if (childIndex == children.Count)
                {
                    return BTNodeState.Failure;
                }
                else
                {
                    childIndex++;
                    return BTNodeState.Running;
                }
            }
            else
            {
                return state;
            }
        }

        protected override void OnStop()
        {

        }
    }
}